<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

   <head> 
      <title>Fletag Archive</title>
      <meta http-equiv="generator" content="PHP Designer 2006 - BETA" />
      <script src="sorttable.js"></script>
      <link href="default.css" rel="stylesheet" type="text/css" media="screen" />
   </head>

   <body>
         <div id="header">
	            <div id="logo">
		          <h1>FLeTaG</h1>
              </div>
         <div id="menu">
		     <ul>
			       <li class="current_page_item"><a href="#">Archive</a></li>
			       <li><a href="http://snafu.org.uk/fletag/scoreboard.php">Scoreboard</a></li>
			       <li class="last"><a href="#">About</a></li>
       </ul>
	     </div>
      </div>
      <div id="page">
           <div id="content">
		            <div class="post">
			               <div class="title">
				                  <h2><a href="#">Archive Scoreboard 2008</a></h2>
				                  <p><small>Click table headers to sort</small></p>
                     </div>
                </div>
           </div>
			<?php
			//Establish the db connection
			require('dbconn.inc.php');
			//Include the function library
			include('functions.inc.php');
			?>

			<?php

					  $scoreboard_sql = "SELECT player, total_points,
                              TRUNCATE(total_points / played,2) as average_points,
                              played, won, drawn, lost
                              FROM players_archive
									 						ORDER BY average_points DESC";

				$result = doQuery($scoreboard_sql);
				
		 		$run = 0;
		 		$rank = 1;
		 		
		 		while ($row = mysql_fetch_array($result))
		 		{
		 		  $player_id = $row['id'];
		 		  $player_name = $row['player'];
					$player_total = $row['total_points'];
					$player_average = $row['average_points'];
					$player_played  = $row['played'];
					$player_won = $row['won'];
					$player_drawn= $row['drawn'];
					$player_lost = $row['lost'];
					$player_prev = $row['prev_position'];
					

					
					if ($run == 0)
					{
						print("<table BORDER cellpadding=5 class=sortable>");
						print("<tr><th>Name</th><th>Total</th><th>Average</th><th>Played</th><th>Won</th><th>Drawn</th><th>Lost</th></tr>");
						$run = 1;
					}
					
					//$colour = getColour($plugin_riskval);
					
					//print("<tr class=$colour><td><a href=/nessrep/host.php?plugin=$plugin_scriptid>$plugin_scriptid</a></td><td>$plugin_name</td>
					//<td>
					//<a class=picture href=/nessrep/host.php?details=$scan_id&hide=1><img src=/nessrep/icons/application_view_detail.png title=Details></a>");
				print ("<tr><td>$player_name</td><td>$player_total</td><td>$player_average</td><td>$player_played</td><td>$player_won</td><td>$player_drawn</td><td>$player_lost</td></tr>");
        $rank++;
				}
					print("</table>");
		 ?>
		 
   <div id="content">
        <div class="post">
             <div class="title">
                  <h2><a href="#">Match Results 2008</a></h2>
             </div>
        </div>
   </div>
   <?php
        $match_sql = "SELECT date,
                     score1,score2,team1,team2,
                     TRUNCATE(points1,2) as team1_points,
                     TRUNCATE(points2,2) as team2_points
                     FROM games_archive ORDER BY date DESC";
                     
        $match_result = doQuery($match_sql);
        
        $run = 0;
        
        while ($row = mysql_fetch_array($match_result))
		 		{
              $game_date = $row['date'];
              $game_score1 = $row['score1'];
              $game_score2 = $row['score2'];
              $game_team1 = $row['team1'];
              $game_team2 = $row['team2'];
              $game_points1 = $row['team1_points'];
              $game_points2 = $row['team2_points'];
              
              if ($run == 0)
					    {
						     print("<table BORDER cellpadding=5>");
                 //print("<tr><th>Date</th><th>Team1</th><th>Score</th><th>Score</th><th>Team2</th></tr>");
						     $run = 1;
              }
              
              print ("<tr><td>$game_date</td><td>$game_team1</td><td>$game_score1($game_points1)</td><td>$game_score2($game_points2)</td><td>$game_team2</td></tr>");
              



        }
        print("</table>");
   
   ?>



   </div>
   </body>
</html>
